package com.rain.utils;

import com.rain.utils.PropertiesUtils;

public class Constants {

    public static Boolean IGNORE_TABLE_PERFIX;
    public static String  SUFFIX_BEAN_PARAM;

    // 文件路径
    public static String PATH_BASE;
    private static String PATH_JAVA  = "java/";
    private static String PATH_RESOURCES = "resources";

    // 包名
    public static String PACKAGE_BASE;

    // 实体类路径
    public static String PACKAGE_ENTITY;
    public static String PACKAGE_ENTITY_PATH;

    // mapper类
    public static String PACKAGE_MAPPER;
    public static String PACKAGE_MAPPER_PATH;

    // mapper - XML类
    public static String PACKAGE_MAPPER_XML;
    public static String PACKAGE_MAPPER_XML_PATH;

    // service
    public static String PACKAGE_SERVICE;
    public static String PACKAGE_SERVICE_PATH;

    // controller
    public static String PACKAGE_CONTROLLER;
    public static String PACKAGE_CONTROLLER_PATH;

    // service_impl
    public static String PACKAGE_SERVICE_IMPL;
    public static String PACKAGE_SERVICE_IMPL_PATH;

    // exception
    public static String PACKAGE_EXCEPTION;
    public static String PACKAGE_EXCEPTION_PATH;

    // 工具类
    public static String PACKAGE_UTILS;
    public static String PACKAGE_UTILS_PATH;

    // 枚举类
    public static String PACKAGE_ENUM;
    public static String PACKAGE_ENUM_PATH;

    // 查询类
    public static String PACKAGE_QUERY;
    public static String PACKAGE_QUERY_PATH;

    // 查询参数
    public static String QUERY_FUZZY;
    public static String QUERY_TIME_START;
    public static String QUERY_TIME_END;

    // 需要忽略的属性
    public static String IGNORE_BEAN_TOJSON_FILED;
    public static String IGNORE_BEAN_TOJSON_EXPRESSION;
    public static String IGNORE_BEAN_TOJSON_CLASS;

    // 日期格式序列化
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;

    // 日期格式反序列化
    public static String BEAN_DATE_UNFORMAT_EXPRESSION;
    public static String BEAN_DATE_UNFORMAT_CLASS;




    public static String AUTHER;


    static {
        IGNORE_TABLE_PERFIX = Boolean.valueOf(PropertiesUtils.getString("ignore.table.prefix"));
        SUFFIX_BEAN_PARAM = PropertiesUtils.getString("suffix.bean.param");

        // 文件路径
        PATH_BASE = PropertiesUtils.getString("path.base");
        PATH_BASE = PATH_BASE + PATH_JAVA + PropertiesUtils.getString("package.base");
        PATH_BASE = PATH_BASE.replace(".","/");

        // 包名
        PACKAGE_BASE = PropertiesUtils.getString("package.base");

        // 实体类路径
        PACKAGE_ENTITY =  PACKAGE_BASE + "." + PropertiesUtils.getString("package.entity");
        PACKAGE_ENTITY_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.entity").replace(".","/") + "/";

        // mapper类
        PACKAGE_MAPPER =  PACKAGE_BASE + "." + PropertiesUtils.getString("package.mapper");
        PACKAGE_MAPPER_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.mapper").replace(".","/") + "/";

        // mapper - xml 类
        //PACKAGE_MAPPER_XML =  PACKAGE_BASE + "." + PATH_RESOURCES + "." + PropertiesUtils.getString("package.mapper");
        PACKAGE_MAPPER_XML_PATH = PropertiesUtils.getString("path.base") + PATH_RESOURCES + "/" + PACKAGE_MAPPER.replace(".","/");

        // service类
        PACKAGE_SERVICE =  PACKAGE_BASE + "." + PropertiesUtils.getString("package.service");
        PACKAGE_SERVICE_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.service").replace(".","/") + "/";

        // service_impl类
        PACKAGE_SERVICE_IMPL =  PACKAGE_BASE + "." + PropertiesUtils.getString("package.service.impl");
        PACKAGE_SERVICE_IMPL_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.service.impl").replace(".","/") + "/";

        // controller类
        PACKAGE_CONTROLLER =  PACKAGE_BASE + "." + PropertiesUtils.getString("package.controller");
        PACKAGE_CONTROLLER_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.controller").replace(".","/") + "/";

        // exception类
        PACKAGE_EXCEPTION =  PACKAGE_BASE + "." + PropertiesUtils.getString("package.exception");
        PACKAGE_EXCEPTION_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.exception").replace(".","/") + "/";

        // 工具类
        PACKAGE_UTILS = PACKAGE_BASE + "." + PropertiesUtils.getString("package.utils");
        PACKAGE_UTILS_PATH =  PATH_BASE + "/" + PropertiesUtils.getString("package.utils").replace(".","/") + "/";

        // 枚举类
        PACKAGE_ENUM = PACKAGE_BASE + "." + PropertiesUtils.getString("package.enum");
        PACKAGE_ENUM_PATH =  PATH_BASE + "/" + PropertiesUtils.getString("package.enum").replace(".","/") + "/";

        // 查询类
        PACKAGE_QUERY = PACKAGE_BASE + "." + PropertiesUtils.getString("package.query");
        PACKAGE_QUERY_PATH = PATH_BASE + "/" + PropertiesUtils.getString("package.query").replace(".","/") + "/";

        // 查询参数
        QUERY_FUZZY = PropertiesUtils.getString("query.fuzzy");;
        QUERY_TIME_START = PropertiesUtils.getString("query.time.start");;
        QUERY_TIME_END = PropertiesUtils.getString("query.time.end");;

        // 需要忽略的属性
        IGNORE_BEAN_TOJSON_FILED = PropertiesUtils.getString("ignore.bean.tojson.filed");
        IGNORE_BEAN_TOJSON_EXPRESSION = PropertiesUtils.getString("ignore.bean.tojson.expression");
        IGNORE_BEAN_TOJSON_CLASS = PropertiesUtils.getString("ignore.bean.tojson.class");

        // 日期格式序列化
        BEAN_DATE_FORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS = PropertiesUtils.getString("bean.date.format.class");

        // 日期格式反序列化
        BEAN_DATE_UNFORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.unformat.expression");
        BEAN_DATE_UNFORMAT_CLASS = PropertiesUtils.getString("bean.date.unformat.class");




        AUTHER = PropertiesUtils.getString("auther");
    }

    public final static String[] SQL_DATE_TIME_TYPES = new String[]{"datetime","timestamp"};
    public final static String[] SQL_DATE_TYPES = new String[]{"date"};
    public static final String[] SQL_DECIMAL_TYPE = new String[]{"decimal","double","float"};
    public static final String[] SQL_STAING_TYPE = new String[]{"char","varchar","text","mediumtext","longtext","enum","text","json"};

    // Integer
    public static final String[] SQL_INTEGER_TYPE = new String[]{"int","tinyint"};

    // Long
    public static final String[] SQl_LONG_TYPE = new String[]{"bigint"};


    public static void main(String[] args) {
        System.out.println(PACKAGE_MAPPER_XML);
        System.out.println(PACKAGE_MAPPER_XML_PATH);
    }
}
